package com.equipment;

import com.util.EncodingUtil;

import java.util.NoSuchElementException;



/**
 * 国标写车辆信息应答D4
 * @author Administrator
 *
 */
public class WriteVehicleInfoResponse {
	private String STX = "55AA"; // 帧开始标志
	private String RSCTL = "00"; // 串口帧序列号
	private String Length = ""; // 数据长度
	private String code = "FD"; // 代码
	private String broadening = "D4"; // 扩展代码
	private String BCC = ""; // 异或校验值

	private String status = "";// 状态
	/**
	 * 解析D4写车辆信息
	 * @param context
	 */
	public void setWriteVehicleInfoResponse(String context){
		if (!context.substring(12, 14).equals("D4")) {
			throw new NoSuchElementException("写车辆命令字错误");
		}
		// 判断是否成功
		if (!context.substring(14, 16).equals("00")) {
			throw new NoSuchElementException("写车辆失败："+ EncodingUtil.getErrorResult(EncodingUtil.hexToDec(context.substring(14, 16))));
		}
		status = context.substring(14, 16);
	}
}
